﻿using System;
using System.Collections.Generic;
using System.Linq;
using Sustainalytics.Entities;
using Sustainalytics.Synchronization.Validation.Entities.CorporateGovernance;
using Sustainalytics.Synchronization.Validation.ValidationRules.Common;

namespace Sustainalytics.Synchronization.Validation.ValidationRules.CorporateGovernance
{
    public class CommentsForAnalystOverviewRule : Rule<GovernanceValidationProfile>
    {
        public override Severity Severity => Severity.Red;
        public override BusinessResearchProduct BusinessResearchProduct => BusinessResearchProduct.CorporateGovernance;
        public override string Code => "RR8";
        public override string InformationalMessage => "Comments for Analyst Overview G.0  Full Profile";

        public CommentsForAnalystOverviewRule()
        {
            For(x => x.CompanyId).When(Validator).WithKey(x => x.CompanyId)
                .WithMessage("The company {0} #{1}# does not have comments for G.0 indicator");
        }

        private static bool Validator(GovernanceValidationProfile validatedProfile, GovernanceValidationProfile referenceProfile)
        {
            if (!validatedProfile.FullProfile)
                return true;

            return !string.IsNullOrWhiteSpace(validatedProfile.AnalystView);
        }
    }
}
